<div class="studypagination">
    <% if @word_pages.length > 1 then  %>
        <% if @story then %>
                <%= if !@word_pages.current.first? then link_to "&lt; Prev", :page=> @word_pages.current.previous, :params => {:story_id => @story.id} else "&lt; Prev" end %> 
                <%= if !@word_pages.current.last? then link_to "Next &gt;", :page=> @word_pages.current.next, :params => {:story_id => @story.id} unless @word_pages.current.last? else "Next &gt;" end %>
        <% else %>
                <%= if !@word_pages.current.first? then link_to "&lt; Prev", :page=> @word_pages.current.previous else "&lt; Prev" end %> 
                <%= if !@word_pages.current.last? then link_to "Next &gt;", :page=> @word_pages.current.next else "Next &gt;" end %>
        <% end %>
    <% end %>
</div>